package com.imachen.ymcc.web.controller;

import com.imachen.ymcc.dto.SmsCodeDto;
import com.imachen.ymcc.enums.GlobalExceptionCode;
import com.imachen.ymcc.result.JSONResult;
import com.imachen.ymcc.service.IVerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifycode")
public class VerifycodeController {

    @Autowired
    private IVerifyService verifyService;

    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult imageCode(@PathVariable("imageCodeKey") String imageCodeKey){
        String base64Str = verifyService.imageCode(imageCodeKey);
        return JSONResult.success(base64Str);
    }


    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody SmsCodeDto smsCodeDto){
        verifyService.sendSmsCode(smsCodeDto);
        return JSONResult.success();
    }



}
